# -*- coding:utf-8 -*-
# @Time:2024/4/1921:01
# @Author:miuzg
# @FileName:new test2.py
# @Software:PyCharm
import requests
import pickle

url = 'http://python.zzhitong.com/login'

data = {
    'pwd': 'zzt666'
}

res = requests.post(url, data=data)

# 登陆成功后会有一个json数据获取他
json_data = res.json()
print(json_data)

if data['msg'] == '登陆成功':
    print('登陆成功')
    print(res.cookies)  # 登陆成功的话可以输出cookie值
    with open('zzt.cookie', 'wb')as f:
        pickle.dump(res.cookies, f)  # 把cookie值写入文件当中
else:
    print('登陆失败')
